<!--
 * @Description: 
 * @Version: 1.0
 * @Autor: Strong
 * @Date: 2021-04-21 09:26:35
 * @LastEditors: Strong
 * @LastEditTime: 2021-04-21 15:44:06
 * @FilePath: \mf\themes\web\zhtw\form.html
-->
<!-- <form action="__INDEX__/form/post" method="post" id="form"> -->
<form id="form" method="post">
    <ul>
        <li>
            <label>姓名<span>*</span></label>
            <input type="text" name="name">
        </li>
        <li>
            <label>電話<span>*</span></label>
            <input type="tel" name="tel">
        </li>
        <li>
            <label>Email<span>*</span></label>
            <input type="email" name="email">
        </li>
        <li>
            <label>留言<span>*</span></label>
            <textarea name="info"></textarea>
        </li>
    </ul>
    <input name="time" type="hidden" id="time" value="<?php echo date('Y-m-d H:i:s') ?>">

    <div class="btn"><button id="submit">送 出</button></div>
</form>


<script> 
    $("#submit").click(function () {
        $(this).attr('disabled')
        var f = $('#form').serializeArray();
        if (f[0].value == '') {
            alert('請輸入您的姓名')
            $(this).removeAttr('disabled')
            return false
        }
        if (f[1].value == '') {
            alert('請輸入您的電話')
            $(this).removeAttr('disabled')
            return false
        }
        if (f[2].value == '') {
            alert('請輸入您的電子郵件')
            $(this).removeAttr('disabled')
            return false
        }
        if (f[3].value == '') {
            alert('請輸入您的需求')
            $(this).removeAttr('disabled')
            return false
        }

        $.ajax({
            type: "POST",
            url: "__INDEX__/form/ajaxPost",
            data: {
                name: f[0].value,
                tel: f[1].value,
                email: f[2].value,
                info: f[3].value,
                time: f[4].value,
                langs:'1',
                form:'contact'
            },
            dataType: "json",
            success: function (data) {
                alert(data.message)
                $(this).removeAttr('disabled')
                f[0].value == ''
                f[1].value == ''
                f[2].value == ''
                f[3].value == ''
            },
        });
    })
</script>